Release 10.1A: OpenEdge Development:
Programming Interfaces
ROWID and RECID data types
Progress provides two structure types to support record fetches. One structure type, the index, you define in the schema of your database. The other structure type, a results list, is temporary; Progress builds it at runtime. The results list associated with a
DO,REPEAT, orOPENQUERYstatement with thePRESELECToption is sometimes called a preselect list.In addition, there are two data types,
ROWIDandRECID, that allow you to retrieve a pointer to a fetched record. You can use this pointer to:In addition to the examples in this section, you can learn more about
ROWIDin OpenEdge Development: Progress 4GL Handbook .Comparing ROWID and RECID
ROWIDis supported by all DataServers. Earlier Progress versions provideRECIDas the only way to fetch a record pointer (supported in this version for backward compatibility).RECIDis limited to a 4-byte record address supported by only a few DataServers and standard Progress.ROWIDprovides a variable byte string that can represent a record address for any type of DataServer. For DataServers that use the 4-byte address supported byRECID(including Progress),ROWIDalso uses a four-4 value. Thus, there is no loss in performance using the more portableROWIDinstead ofRECID.Returning record ROWID values
Progress provides a function named after the
ROWIDdata type to returnROWIDvalues. Given a buffer name, theROWIDfunction returns theROWIDof the current record in the buffer. This example fetches the first customer record, and if it has a balance, refetches it to lock it for update:
Storing and retrieving ROWID and RECID values
As shown in the previous example, you can store
ROWIDvalues inROWIDvariables. You can also store them in work table fields. Thus, the following are validROWIDstorage definitions:
You cannot store
ROWIDvalues in database or temporary tables, but you can store their hexadecimal string representations using theSTRINGfunction. You can then retrieve the string as aROWIDvalue using theTO–ROWIDfunction:
You can store
RECIDvalues directly in a database or temporary table.Additional 4GL support
Several additional statements use
ROWIDandRECIDvalues directly. For example, theREPOSITIONstatement sets the query position to a record given by itsROWIDorRECID. For more information, see the "Results lists" section.Also, because
RECIDis not supported by all DataServers, Progress provides theDBRESTRICTIONSfunction to indicate whether a particular DataServer supports it.Converting from RECID to ROWID
When changing an application to use
ROWIDthat currently usesRECID, you can complete the change with only a keyword substitution if your application:Otherwise, after you change all
RECIDreferences toROWID, you must rewrite your integer references to use character strings. If you use database or temporary tables, you must also convert the relevant fields toCHARACTERfields, and use theSTRINGandTO–ROWIDfunctions to store and retrieveROWIDvalues. However, note that some DataServers build a string for a singleROWIDthat can reach up to several hundred bytes (including a completeWHEREclause).All DataServer tables support
ROWIDreferences except those, such as views, that do not have unique row identifiers. DataServers from earlier Progress versions also supportROWIDreferences. Progress Versions 7.3A and later use an internalRECIDthat transparently converts to aROWIDin the client.Writing DataServer-portable applications
The least portable feature of
ROWIDreferences is the scope of aROWIDreference and when it changes for each DataServer. To maximize portability, follow these rules:
- Always assign values to unique keys before returning the
ROWIDvalue of a record. Some DataServers use a unique key to generate theROWIDvalue.- If you
UNDOaDELETEof a record for which you have stored theROWIDvalue, return theROWIDvalue again after theUNDO. It might be different after the record is recreated.- If you update a unique key value for a record, return its
ROWIDagain to replace any prior value.- Never expect a record to have the same
ROWIDvalue between sessions.Note that each DataServer uses a different method to generate a
ROWIDfor a table, and sometimes for different tables in the same database. Therefore, never expectROWIDvalues to be identical, or even compatible, between otherwise duplicate tables from different DataServers.For more information on
ROWIDvalue construction and scope for your DataServer, see your OpenEdge DataServer guide.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |